import HTMLTestRunner_cn,logging,yagmail,time

t = time.strftime('%Y%m%d%H%M%S',time.localtime())
class Tools:
    # 报告
    def report(self):
        report = HTMLTestRunner_cn.HTMLTestRunner(open(f'{t}.html','wb'),title='A3Mall测试报告')
        return report

    # 日志
    def log(self):
        logging.basicConfig(
            level=logging.DEBUG,
            filename=f'{t}.log',
            format='%(name)s %(message)s %(asctime)s %(thread)d',
            filemode='a'
        )

    # 邮件
    def email(self):
        email = yagmail.SMTP(user='3516922232@qq.com',password='sauvhzrimccccjbi',host='smtp.qq.com')
        email.send(to='3516922232@qq.com',subject='A3mall',contents='附件如下',attachments=[f'{t}.html',f'{t}.log'])
        email.close()